Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Adding source to burnTransaction type #888

Merged

Conversation

sameh-farouk
Copy link
Member

@sameh-farouk sameh-farouk commented Nov 7, 2023

Description:

This PR fixes a bug in the tfchain bridge that cause a transfer to lost when below conditions met:

  • A swap from tfchain to stellar initiated during a bridge downtime
  • The target address on stellar don't have tft trust lines.

Changes:

  • Adding the source account ID to BurnTransaction type and to BurnTransactionExpired
  • Adjusting the BurnTransactionExpired event handler in the bridge daemon to enable refund to take place in a case that wasn't covered before.
  • Updating tfchain go client types.
  • Adding migration module to tft-bridge pallet and storage migration to v2

Why are these changes needed?

Related Issues:

Checklist:

  • My change requires a change to the documentation and I have updated it accordingly
  • My change requires storage migration and I have included and tested it following fork off and try_runtime instructions.
  • I have added tests to cover my changes.
  • My commits follow this conventional commits guide.

@sameh-farouk sameh-farouk marked this pull request as ready for review November 12, 2023 09:29
@sameh-farouk
Copy link
Member Author

Migrations was tested on Devnet live data using try-runtime

try-runtime     --runtime ./tfchain_runtime_fix.compact.compressed.wasm     on-runtime-upgrade     live --uri ws://10.10.0.151:9944
[2023-11-13T02:18:56Z INFO  remote-ext] replacing ws:// in uri with http://: "http://10.10.0.151:9944" (ws is currently unstable for fetching remote storage, for more see https://github.com/paritytech/jsonrpsee/issues/1086)
[2023-11-13T02:18:56Z INFO  remote-ext] since no at is provided, setting it to latest finalized head, 0x7a7ab1e5c925f03e2e1ca75d871f1bf64841c34a3ce22256f1696b9e8a698edf
[2023-11-13T02:18:56Z INFO  remote-ext] since no prefix is filtered, the data for all pallets will be downloaded
[2023-11-13T02:18:56Z INFO  remote-ext] scraping key-pairs from remote at block height 0x7a7ab1e5c925f03e2e1ca75d871f1bf64841c34a3ce22256f1696b9e8a698edf
✅ Found 50739 keys (17.71s)
[00:00:53] ✅ Downloaded key values 955.2937/s [=====================================================================================================] 50739/50739 (0s)
✅ Inserted keys into DB (0.19s)
[2023-11-13T02:20:07Z INFO  remote-ext] adding data for hashed prefix: , took 71.16s
[2023-11-13T02:20:07Z INFO  remote-ext] adding data for hashed key: 3a636f6465
[2023-11-13T02:20:08Z INFO  remote-ext] adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef7f9cce9c888469bb1a0dceaa129672ef8
[2023-11-13T02:20:08Z INFO  remote-ext] adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac
[2023-11-13T02:20:08Z INFO  remote-ext] 👩‍👦 no child roots found to scrape
[2023-11-13T02:20:08Z INFO  remote-ext] initialized state externalities with storage root 0xe205b747e3eacc8c60d92841315cab617f1a429f8ffd388bbca352b921af7359 and state_version V0
[2023-11-13T02:20:09Z INFO  try-runtime::cli] Original runtime [Name: RuntimeString::Owned("substrate-threefold")] [Version: 146] [Code hash: 0xba30...d530]
[2023-11-13T02:20:10Z INFO  try-runtime::cli] New runtime      [Name: RuntimeString::Owned("substrate-threefold")] [Version: 146] [Code hash: 0x88cf...8fba]
[2023-11-13T02:20:10Z WARN  try-runtime::cli] New runtime spec version is not greater than the on-chain runtime spec version. Don't forget to increment the spec version if you intend to use the new code in a runtime upgrade.
[2023-11-13T02:20:11Z INFO  try-runtime::cli] 🚀 Speed up your workflow by using snapshots instead of live state. See `try-runtime create-snapshot --help`.
[2023-11-13T02:20:11Z INFO  try_runtime_core::commands::on_runtime_upgrade] 🔬 Running TryRuntime_on_runtime_upgrade with checks: PreAndPost
[2023-11-13T02:20:11Z INFO  pallet_tfgrid::migrations::v17] current pallet version: V17Struct
[2023-11-13T02:20:11Z INFO  pallet_tfgrid::migrations::v17] 🔎 FixFarmPublicIps pre migration: Number of existing farms 4374
[2023-11-13T02:20:11Z INFO  pallet_tfgrid::migrations::v17] 👥  TFGrid pallet to V17 passes PRE migrate checks ✅
[2023-11-13T02:20:11Z INFO  pallet_tfgrid::migrations::v17]  >>> Unused TFGrid pallet V17 migration
[2023-11-13T02:20:11Z INFO  pallet_tfgrid::migrations::v17] current pallet version: V17Struct
[2023-11-13T02:20:11Z INFO  pallet_tfgrid::migrations::v17] 👥  TFGrid pallet migration to V17Struct passes POST migrate checks ✅
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2] current pallet version: V1
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2] 🔎 MigrateBurnTransactionsV2 pre migration: Number of existing burn transactions 0
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2] 🔎 MigrateBurnTransactionsV2 pre migration: Number of existing executed burn transactions 351
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2] 👥  TFT-BRIDGE pallet to V1 passes PRE migrate checks ✅
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2]  >>> Migrating burn transactions storage...
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2]  <<< burnTransactions migration success, storage version upgraded
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2] current pallet version: V2
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2] 🔎 MigrateBurnTransactionsV2 post migration: Number of existing burn transactions 0
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2] 🔎 MigrateBurnTransactionsV2 post migration: Number of existing executed burn transactions 351
[2023-11-13T02:20:11Z INFO  try_runtime_core::commands::on_runtime_upgrade] 🔬 TryRuntime_on_runtime_upgrade succeeded! Running it again without checks for weight measurements.
[2023-11-13T02:20:11Z INFO  pallet_tfgrid::migrations::v17]  >>> Unused TFGrid pallet V17 migration
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2]  >>> Migrating burn transactions storage...
[2023-11-13T02:20:11Z INFO  pallet_tft_bridge::migrations::v2]  <<< burnTransactions migration success, storage version upgraded
[2023-11-13T02:20:11Z INFO  try_runtime_core::commands::on_runtime_upgrade] 🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency: PreAndPost
[2023-11-13T02:20:11Z INFO  pallet_tfgrid::migrations::v17] current pallet version: V17Struct
[2023-11-13T02:20:12Z INFO  pallet_tfgrid::migrations::v17] 🔎 FixFarmPublicIps pre migration: Number of existing farms 4374
[2023-11-13T02:20:12Z INFO  pallet_tfgrid::migrations::v17] 👥  TFGrid pallet to V17 passes PRE migrate checks ✅
[2023-11-13T02:20:12Z INFO  pallet_tfgrid::migrations::v17]  >>> Unused TFGrid pallet V17 migration
[2023-11-13T02:20:12Z INFO  pallet_tfgrid::migrations::v17] current pallet version: V17Struct
[2023-11-13T02:20:12Z INFO  pallet_tfgrid::migrations::v17] 👥  TFGrid pallet migration to V17Struct passes POST migrate checks ✅
[2023-11-13T02:20:12Z INFO  pallet_tft_bridge::migrations::v2] current pallet version: V2
[2023-11-13T02:20:12Z INFO  pallet_tft_bridge::migrations::v2]  >>> Unused TFT-BRIDGE pallet V2 migration
[2023-11-13T02:20:12Z INFO  pallet_tft_bridge::migrations::v2] current pallet version: V2
[2023-11-13T02:20:12Z INFO  pallet_tft_bridge::migrations::v2] 🔎 MigrateBurnTransactionsV2 post migration: Number of existing burn transactions 0
[2023-11-13T02:20:12Z INFO  pallet_tft_bridge::migrations::v2] 🔎 MigrateBurnTransactionsV2 post migration: Number of existing executed burn transactions 351
[2023-11-13T02:20:12Z INFO  try-runtime::cli] PoV size (zstd-compressed compact proof): 61.0 KB. For parachains, it's your responsibility to verify that a PoV of this size fits within any relaychain constraints.
[2023-11-13T02:20:12Z INFO  try-runtime::cli] Consumed ref_time: 0.043975s (2.20% of max 2s)
[2023-11-13T02:20:12Z INFO  try-runtime::cli] ✅ No weight safety issues detected. Please note this does not guarantee a successful runtime upgrade. Always test your runtime upgrade with recent state, and ensure that the weight usage of your migrations will not drastically differ between testing and actual on-chain execution.

Copy link
Collaborator

@renauter renauter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!!
Added some suggestions
Should also join ADR file to describe changes
Tested on all networks and worked 🎉

substrate-node/runtime/src/lib.rs Show resolved Hide resolved
@sameh-farouk
Copy link
Member Author

@renauter ADR file added and all comments was resolved

@renauter
Copy link
Collaborator

@renauter ADR file added and all comments was resolved

Great! All good, you can "Squash and merge" ;)

@sameh-farouk sameh-farouk merged commit ab138c8 into development Nov 14, 2023
2 checks passed
@sameh-farouk sameh-farouk deleted the development-fix-883-add-source-to-burnTransaction-type branch November 14, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unrecoverable bridge transfer
3 participants